package com.koron.order.experiment.controller;

import com.koron.bean.base.Response;
import com.koron.order.common.bean.dto.OrderDispatchDto;
import com.koron.order.common.controller.OrderDispatchController;
import com.koron.order.experiment.bean.po.ExperimentStatus;
import com.koron.order.experiment.service.ExperimentDispatchService;
import com.koron.order.experiment.service.ExperimentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ExperimentDispatch
 * @description
 * @Author zhouj
 * @Date 2021/10/9 11:30
 */
@Api(tags = "试验工单-派工信息")
@RestController
@RequestMapping("/experiment/dispatch/")
public class ExperimentDispatchController extends OrderDispatchController {

    @Autowired
    private ExperimentDispatchService dispatchService;

    @Autowired
    private ExperimentService experimentService;

    @ApiOperation(value = "新增或更新")
    @PostMapping("saveDispatchInfo")
    public Response<String> saveDispatchInfo(@RequestBody OrderDispatchDto dto) {

        Response<String> response = super.saveDispatchInfo(dto);
        if (dto.getIsCommit()) {
            //修改工单状态 待派工-->待执行
            String orderId = dto.getOrderId();
            Integer submitMaintain = ADOConnection.runTask(getCurrDs(), experimentService, "submitExperiment", Integer.class, orderId, ExperimentStatus.WAIT_EXECUTE.getStatus(), dto);
        }
        return Response.ok(response.getData());

    }

}
